package com.lisa404.ai.conf;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//http://localhost:8080/swagger-ui.html
@Configuration
public class Swagger2Config {
    @Bean
    public OpenAPI UserApiInfo(){
        Info info = new Info()
                .contact(new Contact().email("mingfa@zebralabs.xyz").name("邱明发").url("https://lisa404.com"))
                .version("v1.0.0")
                .title("Lisa404:API")
                .description("本文档描述了用户相关的接口定义");

        // 添加认证
        SecurityScheme securityScheme = new SecurityScheme()
                .type(SecurityScheme.Type.HTTP)
                .scheme("bearer")
                .bearerFormat("JWT");

        Components components = new Components();
        components.addSecuritySchemes("bearerAuth", securityScheme);

        return new OpenAPI()
                .components(components)
                .addSecurityItem(new SecurityRequirement().addList("bearerAuth"))
                .info(info);
    }
}
